knitr::opts_chunk$set(
    echo = TRUE,
    message = FALSE,
    warning = FALSE,
    dev = c("png")
)

Introduction

Load packages

library(Seurat)
library(dplyr)
library(patchwork)
library(DT)
library(SCpubr)
library(tibble)
library(reshape2)
library(viridis)
library(ggpubr)
library(ggplot2)

Open corrected counts and annotated Seurat object

Load the corrected (SoupX), normalized (SCTransformed) and annotated (Twice mapped - Tabula Sapiens Skin reference and PBMC azimuth reference) data.

srat <- readRDS(params$path_to_data)
meta <- srat@meta.data
meta$WHO <- "SD"
meta$WHO[meta$patient %in% c("NeoBCC007_post", "NeoBCC008_post", "NeoBCC012_post", "NeoBCC017_post")] <- "CR"
meta$WHO[meta$patient %in% c("NeoBCC004_post", "NeoBCC006_post", "NeoBCC010_post", "NeoBCC011_post")] <- "PR"
srat <- AddMetaData(srat, meta$WHO, col.name = "WHO")
srat$WHO <- factor(srat$WHO, levels = c("CR", "PR", "SD"))

Define levels and colors

srat@meta.data$anno_l1 <- factor(srat@meta.data$anno_l1, levels=c("other",
                                                                 "Mast cells",
                                                                 "Mono-Mac",
                                                                 "LC",
                                                                 "DC",
                                                                 "pDC",
                                                                 "Plasma cells",
                                                                 "B cells" ,
                                                                 "Proliferating cells",
                                                                 "Natural killer cells",
                                                                 "CD8+ T cells",
                                                                 "Tregs",
                                                                  "CD4+ T cells" ,
                                                                 "Melanocytes",
                                                                 "Endothelial cells",
                                                                 "Fibroblasts",
                                                                 "Keratinocytes",
                                                                 "Malignant cells"))
colors <- c("Malignant cells" = "#bd0026",
           "Keratinocytes" = "#dfc27d",
           "Fibroblasts" = "#f6e8c3",
           "Endothelial cells" = "#54278f",
           "Melanocytes" = "#a65628",
           "CD4+ T cells" = "#b8e186",
           "Tregs" = "#ae017e",
           "CD8+ T cells" = "#fbb4ae",
           "Proliferating cells" = "#b3cde3",
           "Natural killer cells" = "#9e9ac8",
           "B cells" = "#7bccc4",
           "Plasma cells" = "#35978f",
           "pDC" = "#fe9929",
           "DC" = "#e7298a",
           "LC" = "yellow" ,
           "Mono-Mac" = "#fec44f",
           "Mast cells" = "#bf812d",
           "other" = "#bdbdbd")

Figure 3a

p <- SCpubr::do_DimPlot(sample = srat, 
                  colors.use = colors, 
                  group.by = "anno_l1", 
                  pt.size=0.5, label = TRUE, 
                  repel = TRUE, 
                  legend.position = "none",  
                  label.color = "black") + 
     theme_minimal() + 
     NoLegend() + 
     theme(text = element_text(size=20))

p

DT::datatable(p$data, 
              caption = ("Figure 3a"),
              extensions = 'Buttons', 
              options = list( dom = 'Bfrtip',
              buttons = c( 'csv', 'excel')))

Figure 3b

genes <- list( 
               "Mal." = c("KRT17", "EPCAM", "BCAM"),
               "Kerati." = c("FGFBP1", "KRT1", "KRT6A"),
               "Fibro." = c("COL1A1", "COL1A2", "COL6A2"),
               "E" = c("VWF"),
               "Mel" = c("MLANA", "PMEL"),
               "CD4+T" = c("CD3E","CD2", "CD4"  ),
               "Tregs" = c("IL2RA", "CD25", "FOXP3", "TNFRSF4"),
               "CD8+T" = c("CD8A", "GZMA"),
               "NK" = c( "KLRC1", "PRF1", "GNLY"),
               "P" = c("MKI67"),
               "B" = c("MS4A1", "CD19"),
               "Plasma" = c("IGKC", "CD38", "SDC1"),
               "pDC" = c( "IRF8", "CLEC4C"),
               "DC" = c("LAMP3", "CCR7"),
               "LC" = c("CD1A", "CD207"),
               "Mono-Mac" = c("CD68",  "CD14" ),
               "Mast" = c("KIT", "SOCS1"))


p <- SCpubr::do_DotPlot(sample = srat,  
                        features = genes, 
                        group.by = "anno_l1",
                        font.size = 25, 
                        legend.length = 4,  
                        legend.type = "colorbar", 
                        dot.scale = 8)
p

DT::datatable(p$data, 
              caption = ("Figure 3b"),
              extensions = 'Buttons', 
              options = list( dom = 'Bfrtip',
              buttons = c( 'csv', 'excel')))

Not included in the final version of the manuscript

# Subset immune / non-immune cells
imm <- subset(srat, subset = anno_l1 %in% c("other",
                                                                 "Mast cells",
                                                                 
                                                                 "Mono-Mac",
                                                                 "LC",
                                                                 "DC",
                                                                 "pDC",
                                                                 "Plasma cells",
                                                                 "B cells" ,
                                                                 "Proliferating cells",
                                                                 "Natural killer cells",
                                                                 "CD8+ T cells",
                                                                 "Tregs",
                                                                  "CD4+ T cells" ))


other <- subset(srat,subset = anno_l1 %in% c("Malignant cells",
                                                                 "Keratinocytes",
                                                                 "Fibroblasts",
                                                                 "Endothelial cells",
                                                                 "Melanocytes"))

imm$anno_l1 <- droplevels(imm$anno_l1)
other$anno_l1 <- droplevels(other$anno_l1)

# subset pCR and nonpCR for each subset

pCR_imm <- subset(imm, subset = Pathological.Response == "pCR" )

nonpCR_imm <- subset(imm, subset = Pathological.Response == "non-pCR")

pCR_other <- subset(other, subset = Pathological.Response == "pCR" )

nonpCR_other <- subset(other, subset = Pathological.Response == "non-pCR")


### plots

d1 <- SCpubr::do_BarPlot(pCR_other,
                         group.by = "anno_l1",
                         split.by = "patient",
                         position = "fill",
                         order=FALSE,
                         legend.position = "none",
                   flip = TRUE,
                   font.size = 14,
                   colors.use = colors,
                   ylab = "CD45- EPCAM+")

d2 <- SCpubr::do_BarPlot(nonpCR_other,
                         group.by = "anno_l1",
                         split.by = "patient",
                         position = "fill",
                         order=FALSE,
                         legend.position = "none",
                   flip = TRUE,
                   font.size = 14,
                   colors.use = colors,
                   ylab = "CD45- EPCAM+")



d3 <- SCpubr::do_BarPlot(pCR_imm,
                         group.by = "anno_l1",
                         split.by = "patient",
                         position = "fill",
                         order=FALSE,
                         legend.position = "none",
                   flip = TRUE,
                   font.size = 20,
                   colors.use = colors,
                   ylab = "CD45+ EPCAM-")

d4 <- SCpubr::do_BarPlot(nonpCR_imm,
                         group.by = "anno_l1",
                         split.by = "patient",
                         position = "fill",
                         order=FALSE,
                         legend.position = "none",
                   flip = TRUE,
                   font.size = 20,
                   colors.use = colors,
                   ylab = "CD45+ EPCAM-")





p <- d3 +  d4  + plot_layout(ncol = 1, heights = c(1,2))
p

DT::datatable(d3$data, 
              caption = ("Figure 2Ga"),
              extensions = 'Buttons', 
              options = list( dom = 'Bfrtip',
              buttons = c( 'csv', 'excel')))
DT::datatable(d4$data, 
              caption = ("Figure 2Gb"),
              extensions = 'Buttons', 
              options = list( dom = 'Bfrtip',
              buttons = c( 'csv', 'excel')))

Session Info

sessionInfo()
## R version 4.3.0 (2023-04-21)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 22.04.4 LTS
## 
## Matrix products: default
## BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
## LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so;  LAPACK version 3.10.0
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8   
##  [6] LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
## 
## time zone: Europe/Vienna
## tzcode source: system (glibc)
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
##  [1] ggpubr_0.6.0.999   ggplot2_3.5.1      viridis_0.6.5      viridisLite_0.4.2  reshape2_1.4.4     tibble_3.2.1       SCpubr_2.0.2      
##  [8] DT_0.32            patchwork_1.2.0    dplyr_1.1.4        Seurat_5.0.3       SeuratObject_5.0.1 sp_2.1-3          
## 
## loaded via a namespace (and not attached):
##   [1] RColorBrewer_1.1-3     rstudioapi_0.16.0      jsonlite_1.8.8         magrittr_2.0.3         spatstat.utils_3.0-4   farver_2.1.2          
##   [7] rmarkdown_2.26         fs_1.6.4               vctrs_0.6.5            ROCR_1.0-11            memoise_2.0.1          spatstat.explore_3.2-7
##  [13] rstatix_0.7.2          forcats_1.0.0          htmltools_0.5.8        broom_1.0.5            gridGraphics_0.5-1     sass_0.4.9            
##  [19] sctransform_0.4.1      parallelly_1.37.1      KernSmooth_2.23-22     bslib_0.6.2            htmlwidgets_1.6.4      ica_1.0-3             
##  [25] plyr_1.8.9             plotly_4.10.4          zoo_1.8-12             cachem_1.1.0           igraph_2.0.3           mime_0.12             
##  [31] lifecycle_1.0.4        pkgconfig_2.0.3        Matrix_1.6-5           R6_2.5.1               fastmap_1.2.0          fitdistrplus_1.1-11   
##  [37] future_1.33.2          shiny_1.8.1            digest_0.6.35          colorspace_2.1-0       tensor_1.5             RSpectra_0.16-1       
##  [43] irlba_2.3.5.1          crosstalk_1.2.1        labeling_0.4.3         progressr_0.14.0       fansi_1.0.6            spatstat.sparse_3.0-3 
##  [49] httr_1.4.7             polyclip_1.10-6        abind_1.4-5            compiler_4.3.0         withr_3.0.0            backports_1.4.1       
##  [55] carData_3.0-5          fastDummies_1.7.3      highr_0.10             ggsignif_0.6.4         MASS_7.3-60.0.1        tools_4.3.0           
##  [61] lmtest_0.9-40          httpuv_1.6.15          future.apply_1.11.1    goftest_1.2-3          glue_1.7.0             nlme_3.1-164          
##  [67] promises_1.2.1         grid_4.3.0             Rtsne_0.17             cluster_2.1.6          generics_0.1.3         gtable_0.3.5          
##  [73] spatstat.data_3.0-4    tidyr_1.3.1            data.table_1.15.2      car_3.1-2              utf8_1.2.4             spatstat.geom_3.2-9   
##  [79] RcppAnnoy_0.0.22       ggrepel_0.9.5          RANN_2.6.1             pillar_1.9.0           stringr_1.5.1          yulab.utils_0.1.4     
##  [85] spam_2.10-0            RcppHNSW_0.6.0         later_1.3.2            splines_4.3.0          lattice_0.22-6         survival_3.5-8        
##  [91] deldir_2.0-4           tidyselect_1.2.1       miniUI_0.1.1.1         pbapply_1.7-2          knitr_1.45             gridExtra_2.3         
##  [97] scattermore_1.2        xfun_0.43              matrixStats_1.2.0      stringi_1.8.4          lazyeval_0.2.2         yaml_2.3.8            
## [103] evaluate_0.23          codetools_0.2-19       ggplotify_0.1.2        cli_3.6.2              uwot_0.1.16            xtable_1.8-4          
## [109] reticulate_1.35.0      munsell_0.5.1          jquerylib_0.1.4        Rcpp_1.0.12            globals_0.16.3         spatstat.random_3.2-3 
## [115] png_0.1-8              parallel_4.3.0         assertthat_0.2.1       dotCall64_1.1-1        listenv_0.9.1          scales_1.3.0          
## [121] ggridges_0.5.6         leiden_0.4.3.1         purrr_1.0.2            rlang_1.1.4            cowplot_1.1.3